# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

    def forwards(self, orm):
        # Adding model 'Object'
        db.create_table(u'controlpanel_object', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=200)),
        ))
        db.send_create_signal(u'controlpanel', ['Object'])

        # Adding model 'ObjectField'
        db.create_table(u'controlpanel_objectfield', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=200)),
            ('object', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['controlpanel.Object'])),
            ('type', self.gf('django.db.models.fields.CharField')(max_length=2)),
        ))
        db.send_create_signal(u'controlpanel', ['ObjectField'])

        # Adding model 'FieldOption'
        db.create_table(u'controlpanel_fieldoption', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=200)),
            ('field', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['controlpanel.ObjectField'])),
        ))
        db.send_create_signal(u'controlpanel', ['FieldOption'])

        # Adding model 'ObjectForm'
        db.create_table(u'controlpanel_objectform', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=200)),
            ('object', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['controlpanel.Object'])),
        ))
        db.send_create_signal(u'controlpanel', ['ObjectForm'])

        # Adding model 'FormFieldMapping'
        db.create_table(u'controlpanel_formfieldmapping', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('field', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['controlpanel.ObjectField'])),
            ('form', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['controlpanel.ObjectForm'])),
        ))
        db.send_create_signal(u'controlpanel', ['FormFieldMapping'])

        # Adding model 'ObjectList'
        db.create_table(u'controlpanel_objectlist', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=200)),
            ('object', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['controlpanel.Object'])),
        ))
        db.send_create_signal(u'controlpanel', ['ObjectList'])

        # Adding M2M table for field fields on 'ObjectList'
        m2m_table_name = db.shorten_name(u'controlpanel_objectlist_fields')
        db.create_table(m2m_table_name, (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('objectlist', models.ForeignKey(orm[u'controlpanel.objectlist'], null=False)),
            ('objectfield', models.ForeignKey(orm[u'controlpanel.objectfield'], null=False))
        ))
        db.create_unique(m2m_table_name, ['objectlist_id', 'objectfield_id'])

        # Adding model 'Entity'
        db.create_table(u'controlpanel_entity', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
        ))
        db.send_create_signal(u'controlpanel', ['Entity'])


    def backwards(self, orm):
        # Deleting model 'Object'
        db.delete_table(u'controlpanel_object')

        # Deleting model 'ObjectField'
        db.delete_table(u'controlpanel_objectfield')

        # Deleting model 'FieldOption'
        db.delete_table(u'controlpanel_fieldoption')

        # Deleting model 'ObjectForm'
        db.delete_table(u'controlpanel_objectform')

        # Deleting model 'FormFieldMapping'
        db.delete_table(u'controlpanel_formfieldmapping')

        # Deleting model 'ObjectList'
        db.delete_table(u'controlpanel_objectlist')

        # Removing M2M table for field fields on 'ObjectList'
        db.delete_table(db.shorten_name(u'controlpanel_objectlist_fields'))

        # Deleting model 'Entity'
        db.delete_table(u'controlpanel_entity')


    models = {
        u'controlpanel.entity': {
            'Meta': {'object_name': 'Entity'},
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
        },
        u'controlpanel.fieldoption': {
            'Meta': {'object_name': 'FieldOption'},
            'field': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['controlpanel.ObjectField']"}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '200'})
        },
        u'controlpanel.formfieldmapping': {
            'Meta': {'object_name': 'FormFieldMapping'},
            'field': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['controlpanel.ObjectField']"}),
            'form': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['controlpanel.ObjectForm']"}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
        },
        u'controlpanel.object': {
            'Meta': {'object_name': 'Object'},
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '200'})
        },
        u'controlpanel.objectfield': {
            'Meta': {'object_name': 'ObjectField'},
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
            'object': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['controlpanel.Object']"}),
            'type': ('django.db.models.fields.CharField', [], {'max_length': '2'})
        },
        u'controlpanel.objectform': {
            'Meta': {'object_name': 'ObjectForm'},
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
            'object': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['controlpanel.Object']"})
        },
        u'controlpanel.objectlist': {
            'Meta': {'object_name': 'ObjectList'},
            'fields': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['controlpanel.ObjectField']", 'symmetrical': 'False'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
            'object': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['controlpanel.Object']"})
        }
    }

    complete_apps = ['controlpanel']